package com.gxar.quick.ar.server.base.common.enums;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author linsy
 * @version 1.0
 * @created 2023/11/9 09:40
 */
public enum UserWorksTypeEnum {
    MINE(0, "mine", "我的"),
    FAVORITES(1, "favorites", "收藏"),
    EXCHANGE(2, "exchange", "兑换品");

    private final Integer code;
    private final String name;
    private final String desc;

    /**
     * 根据名称查询枚举
     *
     * @param name 名称
     * @return 枚举
     */
    public static UserWorksTypeEnum getByName(String name) {
        UserWorksTypeEnum userWorksTypeEnum = Arrays.stream(UserWorksTypeEnum.values()).filter(e -> e.getName().equals(name)).findFirst().orElse(null);
        if (Objects.nonNull(userWorksTypeEnum)) {
            return userWorksTypeEnum;
        }
        return null;
    }

    UserWorksTypeEnum(Integer code, String name, String desc) {
        this.code = code;
        this.name = name;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public String getDesc() {
        return desc;
    }
}
